<?xml version="1.0" encoding="UTF-8"?>

<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<!--
    POM file.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.apache.ignite</groupId>
        <artifactId>ignite-parent-internal</artifactId>
        <version>${revision}</version>
        <relativePath>../../parent-internal/pom.xml</relativePath>
    </parent>

    <artifactId>ignite-core</artifactId>

    <properties>
        <ignite.update.notifier.product>apache-ignite</ignite.update.notifier.product>
    </properties>

    <dependencies>
        <dependency>
            <groupId>javax.cache</groupId>
            <artifactId>cache-api</artifactId>
            <version>${javax.cache.version}</version>
        </dependency>

        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>${jetbrains.annotations.version}</version>
        </dependency>

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>ignite-tools</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>mx4j</groupId>
            <artifactId>mx4j-tools</artifactId>
            <version>3.0.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>${commons.collections.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>${commons.dbcp.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.8</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.10</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>${h2.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>${mockito.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-servlets</artifactId>
            <version>${jetty.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>${jetty.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.esotericsoftware.kryo</groupId>
            <artifactId>kryo</artifactId>
            <version>2.20</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>c3p0</groupId>
            <artifactId>c3p0</artifactId>
            <version>0.9.1</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>${commons.io.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>${guava.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.javassist</groupId>
            <artifactId>javassist</artifactId>
            <version>${javassist.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${commons.lang3.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>

            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>

        <testResources>
            <testResource>
                <directory>src/test/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </testResource>
            <testResource>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <directory>src/test/config</directory>
                <includes>
                    <include>log4j2-test.xml</include>
                    <include>tests.properties</include>
                </includes>
                <!-- Hide the test logger configuration from the log4j autoconfigurator
                     in case the user starts Ignite with test.jar on the classpath. -->
                <targetPath>${project.build.testOutputDirectory}/test/config</targetPath>
            </testResource>

        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>

                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <includePluginDependencies>true</includePluginDependencies>
                            <mainClass>org.apache.ignite.tools.classgen.ClassesGenerator</mainClass>
                            <arguments>
                                <argument>${project.basedir}/target/classes</argument>
                                <argument>
                                    <![CDATA[
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
                                    ]]>
                                </argument>
                                <argument>org.apache.ignite</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>

                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>properties-augmentation</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>process-resources</phase>
                                <configuration>
                                    <failOnError>false</failOnError>
                                    <target>
                                        <tstamp>
                                            <format property="ignite.rel.date" pattern="ddMMyyyy" locale="en" />
                                        </tstamp>

                                        <property name="props.file" value="../../modules/core/target/classes/ignite.properties" />

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.update.notifier.enabled.by.default=.*" />
                                            <substitution expression="ignite.update.notifier.enabled.by.default=${update.notifier.enabled.by.default}" />
                                        </replaceregexp>

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.rel.date=.*" />
                                            <substitution expression="ignite.rel.date=${ignite.rel.date}" />
                                        </replaceregexp>

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.update.status.params=.*" />
                                            <substitution expression="ignite.update.status.params=ver=${project.version}&amp;product=${ignite.update.notifier.product}" />
                                        </replaceregexp>

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.version=.*" />
                                            <substitution expression="ignite.version=${project.version}" />
                                        </replaceregexp>

                                        <!-- git (to be replaced by git hooks)-->

                                        <exec executable="${git.exec}" outputproperty="ignite.build" failonerror="true">
                                            <arg line="log -1 --format=%ct" />
                                        </exec>

                                        <exec executable="${git.exec}" outputproperty="ignite.revision" failonerror="true">
                                            <arg line="log -1 --format=%H" />
                                        </exec>

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.revision=.*" />
                                            <substitution expression="ignite.revision=${ignite.revision}" />
                                        </replaceregexp>

                                        <replaceregexp file="${props.file}" byline="true">
                                            <regexp pattern="ignite.build=.*" />
                                            <substitution expression="ignite.build=${ignite.build}" />
                                        </replaceregexp>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>jcache-tck</id>

            <properties>
                <domain-lib-dir>${project.build.directory}/domainlib</domain-lib-dir>
                <domain-jar>domain.jar</domain-jar>
            </properties>

            <dependencies>
                <dependency>
                    <groupId>javax.cache</groupId>
                    <artifactId>cache-tests</artifactId>
                    <version>${javax.cache.tck.version}</version>
                </dependency>

                <dependency>
                    <groupId>javax.cache</groupId>
                    <artifactId>cache-tests</artifactId>
                    <classifier>tests</classifier>
                    <version>${javax.cache.tck.version}</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-library</artifactId>
                    <version>${hamcrest.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.8</version>
                        <executions>
                            <!--Required because JUnit will not detect tests simply included in a dep-->
                            <execution>
                                <id>copy-cache-tests</id>
                                <goals>
                                    <goal>unpack-dependencies</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                                    <includeArtifactIds>cache-tests</includeArtifactIds>
                                    <includeScope>test</includeScope>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <systemPropertyVariables>
                                <domainJar>${domain-lib-dir}/${domain-jar}</domainJar>
                                <javax.management.builder.initial>org.apache.ignite.internal.tck.TCKMBeanServerBuilder</javax.management.builder.initial>
                                <org.jsr107.tck.management.agentId>IgniteMBeanServer</org.jsr107.tck.management.agentId>
                                <javax.cache.CacheManager>org.apache.ignite.cache.CacheManager</javax.cache.CacheManager>
                                <javax.cache.Cache>org.apache.ignite.IgniteCache</javax.cache.Cache>
                                <javax.cache.Cache.Entry>org.apache.ignite.internal.processors.cache.CacheEntryImpl</javax.cache.Cache.Entry>
                                <javax.cache.annotation.CacheInvocationContext>javax.cache.annotation.impl.cdi.CdiCacheKeyInvocationContextImpl</javax.cache.annotation.CacheInvocationContext>
                                <IGNITE_QUIET>false</IGNITE_QUIET>
                            </systemPropertyVariables>
                            <excludes>
                                <!-- Parent's pom.xml includes all Ignite test classes (tests, suites) in the surefire plugin.
                                     So need to exclude all of them to test only JCache tests. -->
                                <exclude>**/org/apache/ignite/**/*.java</exclude>
                                <exclude>**/annotation/*Test.java</exclude>
                                <exclude>**/ClientServerTest.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
